/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014年12月29日         luwei
 */

package com.coocaa.launcher.sidebar.setting.item.update;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.coocaa.launcher.sidebar.left.SideItemView;
import com.coocaa.x.uipackage.SkinManager;
import com.tianci.appstore.R;
import com.tianci.appstore.utils.SkyConstants;

public class UpdateItem extends SideItemView {
    public UpdateItem(Context context) {
        super(context);
    }

    @Override
    public String getItemName() {
        // TODO Auto-generated method stub
        return SkinManager.getInstance().getString(R.string.setting_update);
    }

    @Override
    public int getItemIconId() {
        // TODO Auto-generated method stub
        return R.drawable.launcher_icon_set_update;
    }

    @Override
    public View getRightView() {

        if (mRightView == null) {
            TextView view = new TextView(mContext);
            view.setTextAppearance(mContext, R.style.left_side_bar_memory_tip_style);
            view.setTextSize(SkyConstants.Dpi(39));
            mRightView = view;
            LayoutParams params = new LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            params.rightMargin = SkyConstants.Div(100);
            mRightView.setLayoutParams(params);
            mRightView.setVisibility(View.GONE);
        }
        return mRightView;
    }

    public void updateVersionInfo(final String version) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mRightView.setVisibility(View.VISIBLE);
                ((TextView) mRightView).setText(String.format(mContext.getResources().getString(R.string.setting_new_version), version));
                mItemName.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.launcher_update_redpoint, 0);
            }
        });
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
    }

    @Override
    public void destory() {
        // TODO Auto-generated method stub

    }

}
